class: center, middle, inverse, title-slide # ECON 3818 ## Expectations ### Kyle Butts ### 21 July 2021 --- exclude: true --- class: clear, middle <!-- Custom css --> <style type="text/css"> @import url(https://fonts.googleapis.com/css?family=Zilla+Slab:300,300i,400,400i,500,500i,700,700i); /* Create a highlighted class called 'hi' */ .hi { font-weight: 600; } .bw { background-color: rgb(0, 0, 0); color: #ffffff; } .gw { background-color: #d2d2d2; color: #ffffff; } /* Font styling */ .mono { font-family: monospace; } .ul { text-decoration: underline; } .ol { text-decoration: overline; } .st { text-decoration: line-through; } .bf { font-weight: bold; } .it { font-style: italic; } /* Font Sizes */ .bigger { font-size: 125%; } .huge{ font-size: 150%; } .small { font-size: 95%; } .smaller { font-size: 85%; } .smallest { font-size: 75%; } .tiny { font-size: 50%; } /* Remark customization */ .clear .remark-slide-number { display: none; } .inverse .remark-slide-number { display: none; } .remark-code-line-highlighted { background-color: rgba(249, 39, 114, 0.5); } .remark-slide-content { background-color: #ffffff; font-size: 24px; /* font-weight: 300; */ /* line-height: 1.5; */ /* padding: 1em 2em 1em 2em; */ } /* Xaringan tweeks */ .inverse { background-color: #23373B; text-shadow: 0 0 20px #333; /* text-shadow: none; */ } .title-slide { background-color: #ffffff; border-top: 80px solid #ffffff; } .footnote { bottom: 1em; font-size: 80%; color: #7f7f7f; } /* Mono-spaced font, smaller */ .mono-small { font-family: monospace; font-size: 20px; } .mono-small .mjx-chtml { font-size: 103% !important; } .pseudocode, .pseudocode-small { font-family: monospace; background: #f8f8f8; border-radius: 3px; padding: 10px; padding-top: 0px; padding-bottom: 0px; } .pseudocode-small { font-size: 20px; } .super{ vertical-align: super; font-size: 70%; line-height: 1%; } .sub{ vertical-align: sub; font-size: 70%; line-height: 1%; } .remark-code { font-size: 68%; } .inverse > h2 { color: #e64173; font-weight: 300; font-size: 40px; font-style: italic; margin-top: -25px; } .title-slide > h2 { margin-top: -25px; padding-bottom: -20px; color: rgba(249, 38, 114, 0.75); text-shadow: none; font-weight: 300; font-size: 35px; font-style: normal; text-align: left; margin-left: 15px; } .remark-inline-code { background: #F5F5F5; /* lighter */ /* background: #e7e8e2; /* darker */ border-radius: 3px; padding: 4px; } /* 2/3 left; 1/3 right */ .more-left { float: left; width: 63%; } .less-right { float: right; width: 31%; } .more-right ~ * { clear: both; } /* 9/10 left; 1/10 right */ .left90 { padding-top: 0.7em; float: left; width: 85%; } .right10 { padding-top: 0.7em; float: right; width: 9%; } /* 95% left; 5% right */ .left95 { padding-top: 0.7em; float: left; width: 91%; } .right05 { padding-top: 0.7em; float: right; width: 5%; } .left5 { padding-top: 0.7em; margin-left: 0em; margin-right: -0.4em; float: left; width: 7%; } .left10 { padding-top: 0.7em; margin-left: -0.2em; margin-right: -0.5em; float: left; width: 10%; } .left30 { padding-top: 0.7em; float: left; width: 30%; } .right30 { padding-top: 0.7em; float: right; width: 30%; } .thin-left { padding-top: 0.7em; margin-left: -1em; margin-right: -0.5em; float: left; width: 27.5%; } /* Example */ .ex { font-weight: 300; color: #cccccc !important; font-style: italic; } .col-left { float: left; width: 47%; margin-top: -1em; } .col-right { float: right; width: 47%; margin-top: -1em; } .clear-up { clear: both; margin-top: -1em; } /* Format tables */ table { color: #000000; font-size: 14pt; line-height: 100%; border-top: 1px solid #ffffff !important; border-bottom: 1px solid #ffffff !important; } th, td { background-color: #ffffff; } table th { font-weight: 400; } /* Extra left padding */ .pad-left { margin-left: 5%; } /* Extra left padding */ .big-left { margin-left: 15%; margin-bottom: -0.4em; } /* Attention */ .attn { font-weight: 500; color: #e64173 !important; font-family: 'Zilla Slab' !important; } /* Note */ .note { font-weight: 300; font-style: italic; color: #314f4f !important; /* color: #cccccc !important; */ font-family: 'Zilla Slab' !important; } /* Question and answer */ .qa { font-weight: 500; /* color: #314f4f !important; */ color: #e64173 !important; font-family: 'Zilla Slab' !important; } /* Remove orange line */ hr, .title-slide h2::after, .mline h1::after { content: ''; display: block; border: none; background-color: #e5e5e5; color: #e5e5e5; height: 1px; } </style> <!-- From xaringancolor --> <div style = "position:fixed; visibility: hidden"> `\(\require{color}\definecolor{red_pink}{rgb}{0.901960784313726, 0.254901960784314, 0.450980392156863}\)` `\(\require{color}\definecolor{turquoise}{rgb}{0.125490196078431, 0.698039215686274, 0.666666666666667}\)` `\(\require{color}\definecolor{orange}{rgb}{1, 0.647058823529412, 0}\)` `\(\require{color}\definecolor{red}{rgb}{0.984313725490196, 0.380392156862745, 0.0274509803921569}\)` `\(\require{color}\definecolor{blue}{rgb}{0.231372549019608, 0.231372549019608, 0.603921568627451}\)` `\(\require{color}\definecolor{green}{rgb}{0.545098039215686, 0.694117647058824, 0.454901960784314}\)` `\(\require{color}\definecolor{grey_light}{rgb}{0.701960784313725, 0.701960784313725, 0.701960784313725}\)` `\(\require{color}\definecolor{grey_mid}{rgb}{0.498039215686275, 0.498039215686275, 0.498039215686275}\)` `\(\require{color}\definecolor{grey_dark}{rgb}{0.2, 0.2, 0.2}\)` `\(\require{color}\definecolor{purple}{rgb}{0.415686274509804, 0.352941176470588, 0.803921568627451}\)` `\(\require{color}\definecolor{slate}{rgb}{0.192156862745098, 0.309803921568627, 0.309803921568627}\)` </div> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { Macros: { red_pink: ["{\color{red_pink}{#1}}", 1], turquoise: ["{\color{turquoise}{#1}}", 1], orange: ["{\color{orange}{#1}}", 1], red: ["{\color{red}{#1}}", 1], blue: ["{\color{blue}{#1}}", 1], green: ["{\color{green}{#1}}", 1], grey_light: ["{\color{grey_light}{#1}}", 1], grey_mid: ["{\color{grey_mid}{#1}}", 1], grey_dark: ["{\color{grey_dark}{#1}}", 1], purple: ["{\color{purple}{#1}}", 1], slate: ["{\color{slate}{#1}}", 1] }, loader: {load: ['[tex]/color']}, tex: {packages: {'[+]': ['color']}} } }); </script> <style> .red_pink {color: #E64173;} .turquoise {color: #20B2AA;} .orange {color: #FFA500;} .red {color: #FB6107;} .blue {color: #3B3B9A;} .green {color: #8BB174;} .grey_light {color: #B3B3B3;} .grey_mid {color: #7F7F7F;} .grey_dark {color: #333333;} .purple {color: #6A5ACD;} .slate {color: #314F4F;} </style> ## Expectations --- # Outline .hi.orange[Expectation] - Definition - Properties .hi.turquoise[Variance] - Definiton - Properties --- # What are Expectations? We are familiar with expectations. For example, - What salary can I expect to earn after graduating from college? - I will not invest in Facebook because I expect its sock price to fall in the future - If you complete your homework, you should expect to do well on exams In statistics, the idea of expectation has a formal, mathematical definition. Most of econometrics revolves around finding the best .it[conditional expectation] (we'll discuss this concept later in the course) --- # Expectation: Discrete Case First we give the mathematical definition of .hi.orange[expectation] for discrete random variables. Let `\(X\)` be a discrete random variable with pmf `\(p_X(x)\)`. The .hi.purple[expectation] of `\(X\)`, denoted `\(E(X)\)` or `\(\mu\)`, is: $$ E(X)= \sum_{x \in S} x\cdot p_X(x), $$ where `\(S\)` is the sample space and x is a realization of the random variable `\(X\)` The expectation is essentially the .hi[weighted average] of the possible outcomes of `\(X\)`, or the .it[mean]. --- # Example of Discrete Expectation Suppose we roll a six-sided .it[unfair] die. The probability of each outcome is provided below:
x
P_X(x)
1
0.1
2
0.1
3
0.1
4
0.1
5
0.5
6
0.1
What is the expected outcome of a single throw? By definition: `\begin{aligned} E(X) &= \sum_{x=1}^6 x\cdot p_x(x) \\ &= (1\cdot 0.1) + (2\cdot 0.1) + (3\cdot 0.1) + (4\cdot 0.1) + (5\cdot 0.5) + (6\cdot 0.1) \\ &= 4.1 \end{aligned}` --- # Clicker Question -- Midterm Example Assume `\(X\)` can only obtain the values `\(1, 2, 3,\)` and `\(5\)`. Given the following PMF, what is `\(E(X)\)`?
Unfair Die
x
P_X(x)
1
0.1
2
0.2
3
0.2
5
?
<ol type = "a"> <li>1.1</li> <li>3.6</li> <li>3.1</li> <li>Cannot be determined from information</li> </ol> --- # Expectation: Continuous Case How would you define an expectation of a continuous random variable? Let `\(Y\)` be the continuous random variable with pdf `\(f_Y(u)\)`. Then the expectation of `\(Y\)` is $$ E(Y)= \int^\infty_{-\infty}y \cdot f_Y(y) dy $$ This is still a weighted average! `\(y\)` is the value you observe and `\(f_Y(y)\)` is the density which is just the relative likelihood or .it[weight]. .it[Don't forget to multiply by y!] --- # Example of Continuous Expectation Suppose `\(Y\)` is a continuous random variable with the pdf `\(f_Y(y)=3y^2\)` for `\(0<y<1\)`. Then: `\begin{equation} E(Y) = \int_{-\infty}^{\infty}y\cdot f_Y(y) \ dy = \int_{0}^{1}y \cdot 3y^2 \ dy = \int_{0}^{1} 3y^3 \ dy = \left.\frac{3}{4}y^4 \ \right|_0^1 = \frac{3}{4} \end{equation}` --- # Clicker Question Suppose `\(X\)` has a .hi.red_pink[uniform distribution] over `\((a,b)\)` denoted `\(X \sim U(a,b)\)`. That is, `\(f_x(x) = \frac{1}{b-a}\)` for `\(a<x<b\)`. What is `\(E(X)\)`? .more-left[ <img src="data:image/png;base64,#expectations_files/figure-html/unif-dist-1.svg" width="90%" style="display: block; margin: auto;" /> ] .less-right[ <ol type = "a"> <li>\(\frac{b-a}{2}\)</li> <li>\(\frac{b+a}{2}\)</li> <li>\(\frac{1}{b-a}\)</li> <li>\(1\)</li> </ol> ] --- # Midterm Example Consider the probability distribution for random variable X: $$ f(x)=.08x,\ 0\leq x \leq 5 $$ Find `\(E[X]\)` --- # Properties of Expectation A trick that will make our lives easier is that expectations are a .hi.purple[linear operator] which means you can move constants in and out of the `\(E\)` function. Let `\(X, Y\)` be random variables and `\(a, b\)` be constants. Then: - `\(E(a) = a\)` - `\(E(aX) = aE(X)\)` - `\(E(X + b) = E(X) + b\)` - `\(E(aX+b) = aE(X) + b\)` - `\(E(X + Y) = E(X) + E(Y)\)` --- # Clicker Question Suppose that the expected income in Boulder is $90,000 and the tax rate is 10%. Then the post-tax income is Y=0.9X where `\(X\)` is annual income of a Boulder resident. What is the expected post-tax income for a Boulder resident, E(Y)? <ol type = "a"> <li>$8,000</li> <li>$90,000</li> <li>$9,000</li> <li>$81,000</li> </ol> --- # Definition of Variance Recall the variance of a sample is `$$s^2 = \frac{1}{n-1} \sum_{i=1}^n (X_i - \bar{X})^2$$` We can use expectations to define a similar expression for the population variance. Let `\(X\)` be a random variable with `\(E(X)< \infty\)`. Then the .hi.turquoise[variance] of `\(X\)` is: $$ Var(X) = E[(X-E(X))^2] $$ Imagine writing this out as an integral and solving it. Would not be fun. .it[Instead, we will be using a much simpler equation to calculate variance...] --- # Alternate Form Note that we can write, `\begin{aligned} Var(X) &= E[ \left(X - E(X) \right)^2 ] = E[ X^2 - 2X\cdot E(X) + [E(X)]^2 ] \\ &= E(X^2) - 2E(X)\cdot E(X) + [E(X)]^2 \\ &= E(X^2) - 2[E(X)]^2 + [E(X)]^2 \\ &= E(X^2) - [E(X)]^2, \end{aligned}` `$$Var(X)=E(X^2)-[E(X)]^2$$` is a much simpler expression of variance (and the one you should use!) --- # Properties of Expectation We can compose E with a function of a random variable, g(X). $$ E[g(X)]= \sum_{x\in S} g(x) \cdot p_x(x) $$ The result is the expected value of g(X). We will use this property to calculate `\(E[X^2]\)` --- # Example While `\(E(X)\)` is called the .hi.green[first moment], we call `\(E(X^2)\)` the .hi.orange[second moment] of X. Therefore, we calculate `\(E[X^2]\)` using the following equation: $$ E[X^2] = \sum x^2*p_X(x) $$ or in the continuous case $$ \int_{-\infty}^\infty x^2 f_X(x) dx $$ --- # Example Let `\(X\)` be the number of heads in two coin flips. $$ E(X) = 0 \cdot (\frac{1}{4})+ 1 \cdot (\frac{1}{2}) + 2 \cdot (\frac{1}{4}) = \frac{1}{2} + \frac{1}{2} = 1 $$ -- $$ E(X^2) = 0^2 \cdot (\frac{1}{4})+ 1^2 \cdot (\frac{1}{2}) + 2^2 \cdot (\frac{1}{4}) = \frac{1}{2} + 1 = \frac{3}{2} ^{\color{red_pink}*} $$ This means that `$$V(X)=E(X^2)-[E(X)]^2 = \frac{3}{2}-1^2 = \frac{1}{2}$$` .footnote[.red_pink[<sup>*</sup>].hi[Never] square probabilities when solving \(E(X^2)\). Only square \(X\) values] --- # Properties of Variance There are several important properties of the variance operator: - `\(Var(a) = 0\)` - `\(Var(aX) = a^2Var(X)\)` - `\(Var(aX+b) = a^2Var(X)\)` - `\(Var(aX+bY) = a^2Var(X)+b^2Var(Y)+2ab\cdot Cov(X,Y).\)`<sup>.red_pink[*]</sup> .footnote[.red_pink[<sup>*</sup>] We will discuss more about covariance later, when `\(X\)` and `\(Y\)` are independent then the covariance is zero] --- # Clicker Question Recall that in Boulder the mean income is $90,000 and the tax rate is 10%. Suppose that the variance of income in Boulder is $1,000. What is the variance of post-tax income, `\(Y=0.9X\)`? <ol type = "a"> <li>$900</li> <li>$1000</li> <li>$810</li> <li>$800</li> </ol> --- # Midterm Example Consider the probability distribution for random variable Y $$ f(x)=.08x, 0\leq x \leq 5 $$ Find `\(V[X]\)`: `\begin{aligned} V[X] &= \int_{-\infty}^\infty x^2 * f(x) \ dx - \left[ \int_{-\infty}^\infty x * f(x) \ dx \right]^2 \\ &= \int_0^5 x^2 * .08x \ dx - \left[\int_0^5 x * .08x \ dx \right]^2= \int_0^5 .08x^3 \ dx - \left[ \int_0^5 .08x^2 \ dx \right]^2 \\ &= \frac{.08x^4}{4} \ \Big|_0^5 - \left( \frac{.08x^3}{3} \ \Big|_0^5\right) ^2= 12.5-(3.3)^2=1.61 \end{aligned}` --- # Midterm Example Consider the probability distribution for random variable X:
x
P_X(x)
2
0.19
4
0.07
6
0.35
8
p
1. Find the expectation of X 2. Find the variance of X 3. A friend says, the expected value of `\(X\)` is 5. To justify this he says, "Well `\(X\)` could be 2,4,6, or 8, so the average is `\(\frac{2+4+6+8}{4} = 5\)`". Why is your friend wrong? Why isn't `\(E[X]=5?\)` (1-2) sentences. 4. Let `\(Y\sim N(4,1)\)`. Random variable `\(W\)` is defined as `\(W=2X+3Y\)`. Given your information about the random variables `\(X\)` and Y. What is `\(E[W]\)`? What is `\(Var[W]\)`? (assuming `\(X\)` & `\(Y\)` are independent) } --- # Midterm Example Consider the probability distribution for random variable Y: $$ f(y)= 8y, 0\leq y \leq \frac{1}{2} $$ 1. Find `\(E[Y]\)` 2. Find `\(P(Y<\frac{1}{3})\)` 3. Find `\(P(Y=\frac{1}{4})\)` 4. Find `\(V[Y]\)` 5. Find `\(P(\frac{3}{4}<Y<1)\)`